package com.yijushequ.action.place;


import com.yijushequ.action.BasicAction;
import com.yijushequ.dao.BaseUserDao;
import com.yijushequ.domain.BaseUser;
import com.yijushequ.domain.PlaceMark;
import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Namespace;
import org.apache.struts2.convention.annotation.Result;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;

@Controller
@Scope(BeanDefinition.SCOPE_PROTOTYPE)
@Namespace(BasicAction.BASE_NAME_SPACE)
public class PlaceAction extends BasicAction {

    private PlaceMark placeMark;

    private BaseUserDao baseUserDao;


    @Action(value = "plaC",
            results = {@Result(name = SUCCESS, type = "tiles", location = ".createProduct")}
    )
    public String plaC() throws Exception {
        BaseUser baseUser = baseUserDao.findById(placeMark.getOwner().getId());
        placeMark.setOwner(baseUser);
        super.getModelDao().persist(placeMark);
        return SUCCESS;
    }


    @Action(value = "plaIni",
            results = {@Result(name = SUCCESS, type = "tiles", location = ".map")}
    )
    public String plaIni(){
        return SUCCESS;
    }

    public PlaceMark getPlaceMark() {
        return placeMark;
    }

    public void setPlaceMark(PlaceMark placeMark) {
        this.placeMark = placeMark;
    }

    public BaseUserDao getBaseUserDao() {
        return baseUserDao;
    }

    public void setBaseUserDao(BaseUserDao baseUserDao) {
        this.baseUserDao = baseUserDao;
    }
}
